@ECHO OFF

SET phpdir=C:\php
SET au2dir=C:\programy\au2

REM checking if filename is given as parameter
IF %1=="" GOTO USAGE

REM checking if php.exe exists
IF NOT EXIST %phpdir%\php-win.exe GOTO PHPNOTFOUND

REM checking if au2 directory exists
IF NOT EXIST %au2dir%\au2.php GOTO AU2NOTFOUND


set startdir=%CD%
pushd %au2dir%

IF exist %1  %phpdir%\php-win.exe %au2dir%\au2.php %1 
IF not exist %1 if exist %startdir%\%1 %phpdir%\php-win.exe %au2dir%\au2.php %startdir%\%1 
IF not exist %1 if not exist %startdir%\%1 echo AU2 template '%1' not found :(

popd


GOTO END

:USAGE
ECHO Usage: au2 filename
GOTO END

:PHPNOTFOUND
ECHO PHP executable not found. Edit SET phpdir= line
GOTO END

:AU2NOTFOUND
ECHO AU2 directory not found. Edit SET au2dir= line
GOTO END



:END

@ECHO ON
